//
//  InboxViewController.m
//  Socrates
//
//  Created by shy on 15/3/29.
//  Copyright (c) 2015年 shy. All rights reserved.
//

#import "InboxViewController.h"

#import "MessageCell.h"
#import "CommentMessageSendView.h"
#import "CommentViewController.h"

typedef enum {
    kLimitation_total_num_item = 0,
    kLimitation_male_num_item,
    kLimitation_female_num_item,
    kLimitation_Num,
} LimitationItems;

static const int kLimitationRowHeight = 95;

@interface InboxViewController () {

}
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation InboxViewController

- (void) viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:239/255. green:239/255. blue:244/255. alpha:1.];
    self.navigationController.navigationBar.hidden = NO;
    [self.tableView registerNib:[UINib nibWithNibName:@"MessageCell" bundle:nil] forCellReuseIdentifier:@"MessageCellIdentifier"];
    self.tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
    self.tableView.separatorColor = [UIColor lightGrayColor];
    self.tableView.tableFooterView = [[UIView alloc] init];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return kLimitationRowHeight;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return kLimitation_Num;
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    // Remove seperator inset
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    
    // Prevent the cell from inheriting the Table View's margin settings
    if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
        [cell setPreservesSuperviewLayoutMargins:NO];
    }
    
    // Explictly set your cell's layout margins
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

- (MessageCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MessageCellIdentifier"];
    UIView *selectView = [[UIView alloc] init];
    selectView.backgroundColor = [UIColor lightGrayColor];
    cell.selectedBackgroundView = selectView;
    
//    RSTTopic *topic = [topicsArray_ objectAtIndex:indexPath.row];
    cell.userName.text = @"AngelaBaby";
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
    [self launchCommentViewController];
}

- (void)launchCommentViewController {
    CommentViewController *vc = [[CommentViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

@end
